{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" name="add_article" id="add_article" enctype="multipart/form-data">
                        <input type="hidden" name="id" value="{$res.id}">

                        <div class="form-group">
                            <label class="col-sm-3 control-label">标题：</label>
                            <div class="input-group col-sm-4">
                                <input id="title" type="text" class="form-control" name="title" value="{$res.activity_name}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">图片：</label>
                            <div class="input-group col-sm-5">
                                <input type="hidden" id="data_photo" name="images" value="{$res.activity_img}">
                                <div id="imgPicker" style="float:left">选择图片</div>
                                <img id="img_data" height="100px" style="float:left;margin-left: 50px;margin-top: -10px;cursor:pointer;" src="{$res.activity_img}" onerror="this.src='/static/admin/images/no_img.jpg'" onclick='imgDisplay(this)'/>
                                <div id="fileList" class="uploader-list" style="float:right"></div>
                            </div>
                        </div>


            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-3">
                    <button class="btn btn-primary btsave"  type="button"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                    <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                </div>
            </div>
            </form>
        </div>
    </div>

</div>
</div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    //上传图片
    wk.upload("{:url('Upload/upload')}",2);
</script>
<script>
    $(".btsave").on('click',function () {
        var formData = new FormData($("#add_article" )[0]);
        $.ajax({
            url: "{:url('update')}",
            type: "post",
            dataType: "json",
            async: false,//1，这四个要写上，否则点击没反应
            cache: false,//2
            contentType: false,//3
            processData: false,//4
            data: formData,
            success: function (data) {
                if (data.code == 200) {
                    wk.success(data.msg,1,"{:url('benefit/index')}");
                } else if(data.code==100){
                    $('.btn').removeAttr('disabled');
                    wk.error(data.msg,2,'');
                    return false;
                }
            }
        });
    })
</script>
</body>
</html>